package com.golddaymicromall.adapter;

import java.util.List;


import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.golddaymicromall.activity.R;
import com.golddaymicromall.bean.ProductInfo;
import com.golddaymicromall.model.HttpModel;

public class GoodsValueAdvrstAdapter extends PagerAdapter {

    private List<ProductInfo> list;
    private Context ctx;

    public GoodsValueAdvrstAdapter(List<ProductInfo> list, Context ctx) {
        this.list = list;
        this.ctx = ctx;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        // TODO Auto-generated method stub
        return arg0 == arg1;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = View.inflate(ctx, R.layout.item_goodsvaluetop, null);
        ImageView img = (ImageView) view.findViewById(R.id.GoodsValueItem_Img);

        Glide.with(ctx)
                .load(new HttpModel().XINAGQINGIMGURL+list.get(position).getImage1())
                .fitCenter()
                .into(img);
        container.addView(view);
        return view;
    }
}
